home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 October / enter-2005-10.iso / files / jedit42install.exe / {app} / macros / Misc / HyperSearch_Results_to_Buffer.bsh < prev    next >
Encoding:
Text File  |  2004-08-29  |  2.3 KB  |  86 lines

  1. /*
  2.  * HyperSearch_Results_to_Buffer.bsh - a Beanshell macro
  3.  * for jEdit text that writes HyperSearch results
  4.  * matches to a new buffer in the format:
  5.  *
  6.  * <filename> :<linenum>: <line text>
  7.  *
  8.  * Copyright (C) 2002, 2003 Ollie Rutherfurd <oliver@rutherfurd.net>
  9.  *
  10.  * This program is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU General Public License
  12.  * as published by the Free Software Foundation; either version 2
  13.  * of the License, or any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  * GNU General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to the Free Software
  22.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  23.  *
  24.  * $Id: HyperSearch_Results_to_Buffer.bsh,v 1.1 2003/11/12 00:24:11 spestov Exp $
  25.  */
  26.  
  27. writeHypersearchResultsToBuffer(View view){
  28.     hs = view.getDockableWindowManager().getDockableWindow("hypersearch-results");
  29.     if (hs == null)
  30.     {
  31.         Macros.error(view, "The 'HyperSearch Results' window is not open.");
  32.         return;
  33.     }
  34.  
  35.     root = hs.getTreeModel().getRoot();
  36.     if(root == null)
  37.     {
  38.         Macros.error(view, "No HyperSearch matches.");
  39.         return;
  40.     }
  41.  
  42.     node = root.getFirstChild();
  43.     while(node.getNextSibling() != null)
  44.     {
  45.         node = node.getNextSibling();
  46.     }
  47.     node = node.getFirstChild();
  48.  
  49.     results = new StringBuffer();
  50.     while(node != null)
  51.     {
  52.         path = node.getUserObject().toString();
  53.         match = node.getFirstChild();
  54.         while(match != null)
  55.         {
  56.             text = match.getUserObject().str;
  57.             results.append(path + " :" + text + "\n");
  58.             match = match.getNextSibling();
  59.         }
  60.         node = node.getNextSibling();
  61.     }
  62.  
  63.     text = results.toString();
  64.     if(text.length() > 0)
  65.     {
  66.         jEdit.newFile(view);
  67.         view.getTextArea().setText(text);
  68.     }
  69. }
  70.  
  71. writeHypersearchResultsToBuffer(view);
  72.  
  73. /*
  74.     Macro index data (in DocBook format)
  75.  
  76. <listitem>
  77.     <para><filename>HyperSearch_Results_to_Buffer.bsh</filename></para>
  78.     <abstract><para>
  79.     Writes HyperSeach results to a new buffer.
  80.     </para></abstract>
  81. </listitem>
  82.  
  83. */
  84.  
  85. // :wrap=none:collapseFolds=0:noTabs=false:lineSeparator=\n:maxLineLen=80:indentSize=4:deepIndent=false:folding=none:
  86.